package org.jackysoft.struts2.fileserver;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.annotations.Logger;
import org.jackysoft.entity.FileItem;
import org.jackysoft.entity.Folder;
import org.jackysoft.service.FileDataService;
import org.jackysoft.struts2.UtilsCRUDAction;
import org.jackysoft.util.OperationType;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;


@Namespace("/fileserver/file")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Logger(label="文件",logType=OperationType.User)
public class FileDataAction extends UtilsCRUDAction<FileItem> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4509774208555990998L;  
	private Folder folder;
	private Collection<String> fileIds;	

	/**
	 * 根据文件夹获取文件列表
	 * 根据传入参数不同,返回文件
	 * <dd> type=received
	 *      返回已收文件
	 * <dd> type=sent
	 *      返回已发文件
	 * <dd> type=uploaded
	 *      根据folder.id 返回该文件夹里的上传文件或者其他文件
	 * */
	public String typedfile() throws Exception{
		this.searchMap.clear();
		this.searchMap.put(Folder.class.getName(), folder);
		getJson();
		return JQGRID;
	}
	
	@Resource
	public void setFileService(FileDataService fileService) {
	    this.setDataProvider(fileService);
	}

	public Folder getFolder() {
		return folder;
	}

	public void setFolder(Folder folder) {
		this.folder = folder;
	}


	public Collection<String> getFileIds() {
		return fileIds;
	}


	public void setFileIds(Collection<String> fileIds) {
		this.fileIds = fileIds;
	}

	@Resource
	public void setService(FileDataService service) {		
		this.setDataProvider(service);
	}
	

}
